/*
 This file is part of BTStracker
		
    BTStracker is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    BTStracker is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.	
	author: azbest.pro (azbest.pro@gmail.com)
*/
package pl.vdl.azbest.mremote.gui.composite;

import java.io.InputStream;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;

import pl.vdl.azbest.log.LoggingTheGathering;
import pl.vdl.azbest.mremote.cmd.Command;
import pl.vdl.azbest.mremote.cmd.Cmd_sendCommCommand;
import pl.vdl.azbest.mremote.cmd.Cmd_swichLoggingOff;
import pl.vdl.azbest.mremote.cmd.Invoker;

import pl.vdl.azbest.mremote.gui.GUIFacade;
import pl.vdl.azbest.mremote.probe.signal.CellSignalProbe;

public class CompositeCommSend extends Composite {

	private Group group = null;

	private Button button = null;

	private Text text = null;

	private Button button1 = null;

	public CompositeCommSend(Composite parent, int style) {
		super(parent, style);
		initialize();
		init();
	}
	{
		LoggingTheGathering.addPath(getClass().getName());
	}

	private void initialize() {
		GridLayout gridLayout = new GridLayout();
		gridLayout.numColumns = 2;
		this.setLayout(gridLayout);
		createGroup();
		setSize(new Point(317, 55));
		this.addDisposeListener(new org.eclipse.swt.events.DisposeListener() {
			public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
				GUIFacade.getInstance().removeComposite(CompositeCommSend.this);
			}
		});
	}

	/**
	 * This method initializes group
	 *
	 */
	private void createGroup() {
		GridData gridData11 = new GridData();
		gridData11.horizontalAlignment = GridData.FILL;
		gridData11.grabExcessHorizontalSpace = true;
		gridData11.horizontalSpan = 2;
		gridData11.verticalAlignment = GridData.CENTER;
		GridData gridData = new GridData();
		gridData.widthHint = 200;
		gridData.verticalAlignment = GridData.CENTER;
		gridData.grabExcessHorizontalSpace = false;
		gridData.horizontalAlignment = GridData.FILL;
		GridLayout gridLayout1 = new GridLayout();
		gridLayout1.numColumns = 3;
		GridData gridData1 = new GridData();
		gridData1.verticalSpan = 2;
		group = new Group(this, SWT.NONE);
		group.setLayoutData(gridData11);
		group.setText("Type to send data to comm port");
		group.setLayoutData(gridData1);
		group.setLayout(gridLayout1);
		button1 = new Button(group, SWT.NONE);
		button1.setText("start bts checker");
		button1.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
			public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
				CellSignalProbe.getInstance().doCheck();
			}
		});
		text = new Text(group, SWT.BORDER);
		text.setSize(new Point(74, 17));
		text.setLayoutData(gridData);


		button = new Button(group, SWT.NONE);
		button.setText("Send command");
		button
				.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
					public void widgetSelected(
							org.eclipse.swt.events.SelectionEvent e) {
						Command c = new Cmd_sendCommCommand(text.getText());
						Invoker.getInstance().addCommand(c);
						Invoker.getInstance().execute();
					}
				});
	}

	private void init() {
		GUIFacade.getInstance().addComposite(this);
	}
	public InputStream getTextInputStream() {
		//return new TextInputStream();
		return System.in;
	}

} // @jve:decl-index=0:visual-constraint="84,4"
